package com.hpu.service;

import android.content.Context;
import android.os.Handler;

import com.hpu.callback.SchoolNewsCallback;
import com.hpu.callback.XueyuanNewsCallback;
import com.hpu.constants.HttpConstants;
import com.hpu.constants.ShareConstants;
import com.hpu.constants.UrlConstants;
import com.hpu.interceptor.ReceivedCookieInterceptor;
import com.hpu.tools.InternetTools;
import com.hpu.tools.OkHttpTools;
import com.hpu.tools.ShareTools;

/**
 * 最新公告业务类，获取40条最新公告的标题与id
 * @author Administrator
 *
 */
public class NewsService{

	private Handler handler;
	
	private Context context;
	
	public NewsService(Handler handler,Context context) {
		this.handler=handler;
		this.context=context;
	}
	
	public void getSchoolNews() {
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
		OkHttpTools.getByCookie(new ReceivedCookieInterceptor(context),UrlConstants.INTERFACE_SCHOOL_NEWS,
				ShareTools.get(context, ShareConstants.STORE_LOGINCOOKIE, "").toString(),
				new SchoolNewsCallback(handler));
	}
	
	public void getXueyuanNews() {
		if(InternetTools.statusInternet(context)==InternetTools.NO_INTERNET)
			handler.sendEmptyMessage(HttpConstants.NO_INTERNET);
		else
		OkHttpTools.getByCookie(new ReceivedCookieInterceptor(context),UrlConstants.INTERFACE_XUEYUAN_NEWS,
				ShareTools.get(context, ShareConstants.STORE_LOGINCOOKIE, "").toString(),
				new XueyuanNewsCallback(handler));
	}

}

